home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / kriegspi / traps.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-30  |  1.2 KB  |  49 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Header: traps.c,v 1.2 87/02/12 11:11:36 schoch Exp $";
  3. #endif
  4.  
  5. #include "externs.h"
  6. #include <signal.h>
  7.  
  8. trap_sigint ()
  9. {
  10.     int y, x;
  11.     char c;
  12.  
  13.     signal (SIGINT, SIG_IGN);
  14.     getyx (stdscr, y, x);
  15.     overwrite (stdscr, backupscreen);
  16.     overwrite (win [PROMPT], backupwin[PROMPT]);
  17.     overwrite (win [MESSAGE], backupwin[MESSAGE]);
  18.     overwrite (win [INPUT], backupwin[INPUT]);
  19.     overwrite (blankscreen, stdscr);
  20.     wclear (win [PROMPT]);
  21.     wclear (win [MESSAGE]);
  22.     wclear (win [INPUT]);
  23.     waddstr (win [PROMPT], "Quit?");
  24.     waddstr (win [MESSAGE], "type y or n");
  25.     waddstr (win [INPUT], ": ");
  26.     move (win [INPUT]->_cury + win [INPUT]->_begy,
  27.           win [INPUT]->_curx + win [INPUT]->_begx);
  28.     refresh ();
  29.     c = getchar();
  30.     while (c!='n' && c!='N' && c!='y' && c!='Y') {
  31.         if (c == '\f')  /*  ^L */
  32.             refresh ();
  33.         c = getchar();
  34.     }
  35.     if (c == 'y') {
  36.         if (out)
  37.             fputs("resign\r\n", out);
  38.         error ((char *) NULL);
  39.     }
  40.     overwrite (backupscreen, stdscr);
  41.     overwrite (backupwin [PROMPT], win [PROMPT]);
  42.     overwrite (backupwin [MESSAGE], win [MESSAGE]);
  43.     overwrite (backupwin [INPUT], win [INPUT]);
  44.     move (y, x);
  45.     touchwin (stdscr);
  46.     redraw ();
  47.     signal (SIGINT, trap_sigint);
  48. }
  49.